﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace _02_创建泛型类
{
    class T_List<T>
    {
        public T_ListNode<T> First { get; set; }
        public T_ListNode<T> Last { get; set; }

        private T_ListNode<T> pro;
        public void Add(T node)
        {
            pro = new T_ListNode<T>(node);
            if (First == null)
            {
                this.First = pro;
                this.Last = pro;

                this.First.Prev = First;
                this.First.Next = First;
            }
            else
            {
                pro.Prev = this.Last;
                this.Last.Next = pro;
                this.Last = pro;
            }
        }
        public IEnumerator GetEnumerator()
        {
            T_ListNode<T> proNode = this.First;
            while (proNode != null)
            {
                yield return proNode.Values;
                proNode = proNode.Next;
            }
        }
    }
    class T_ListNode<T>
    {
        private T values;
        public T Values 
        {
            get { return this.values; }
        }
      
        public T_ListNode<T> Next { get; set; }
        public T_ListNode<T> Prev { get; set; }
        public T_ListNode(T values)
        {
            this.values = values;
        }
   
      
    }
  
}
